package book.shape;

/**
 * 图形类
 */
abstract class PlaneGraphics {
    private String shape;

    /**
     * 构造函数
     *
     * @param shape 形状
     */
    public PlaneGraphics(String shape) {
        this.shape = shape;
    }

    public PlaneGraphics() {
        this("未知图形");
    }

    /**
     * 计算面积
     *
     * @return 图形面积
     */
    public abstract double area();

    /**
     * 打印形状和面积
     */
    public void showShape() {
        System.out.println(this.shape + "面积为" + this.area());
    }

    /**
     * 修改形状
     *
     * @param shape 形状
     */
    public void changeShape(String shape) {
        this.shape = shape;
    }
}
